package thread;

public class ReverseString {
    public void reverseString(char[] s) {
        int strLength = s.length;
        int first = 0;
        int end = strLength - 1;

        for (int i = 0; i < strLength / 2; i++) {
            swapStr(s, first, end);
            first++;
            end--;
        }
    }

    void swapStr(char[] str, int first, int end) {
        if (first == end) {
            str[first] = str[end];
        } else {
            char temp = str[end];
            str[end] = str[first];
            str[first] = temp;
        }
    }
}
